package org.example.struct.array2;

/**
 * @author liyishan
 * @date 2023/9/28 10:51
 * @apiNote
 */

public class Test00153FindMin {


    public int test1(int[] nums) {
        int min = nums[0];
        for(int i =1;i<nums.length; i++){
            if(nums[i] < min){
                min = nums[i];
            }
        }
        return min;
    }

    public int test2(int[] nums) {
        int low = 0;
        int high = nums.length - 1;
        while (low < high) {
            int pivot = low + (high - low) / 2;
            if (nums[pivot] < nums[high]) {
                high = pivot;
            } else {
                low = pivot + 1;
            }
        }
        return nums[low];
    }


}
